﻿package uiresource.map
{
    import com.greensock.*;
    import com.sh.game.util.*;
    import flash.events.*;
    import morn.core.components.*;

    public class SCityPointUI extends View
    {
        public var btn:Button;
        public var img:UrlImage;
        public var _Nmtxt:Label;
        public var leveltxt:Label;
        private var _func:Function;
        private var _clickfunc:Function;
        private var _data:Object;

        public function SCityPointUI(param1:Function, param2:Function)
        {
            this._func = param1;
            this._clickfunc = param2;
            return;
        }// end function

        override protected function createChildren() : void
        {
            loadUI("SCityPoint.xml");
            return;
        }// end function

        override protected function initialize() : void
        {
            super.initialize();
            this.btn.visible = false;
            this.img.addEventListener(MouseEvent.ROLL_OVER, this.rollOverHandler);
            this.addEventListener(MouseEvent.ROLL_OUT, this.rollOutHandler);
            this.img.addEventListener(MouseEvent.CLICK, this.touchHandler2);
            this.btn.addEventListener(MouseEvent.CLICK, this.triggeredHandler);
            return;
        }// end function

        protected function touchHandler2(event:MouseEvent) : void
        {
            event.stopPropagation();
            if (this._clickfunc != null)
            {
                this._clickfunc(this.data);
            }
            return;
        }// end function

        protected function triggeredHandler(event:MouseEvent) : void
        {
            event.stopPropagation();
            if (this.data.mapid == 0)
            {
            }
            this._func(this.data.mapid);
            return;
        }// end function

        protected function clickHandler(event:MouseEvent) : void
        {
            if (this._clickfunc != null)
            {
                this._clickfunc(this.data);
            }
            return;
        }// end function

        protected function rollOutHandler(event:MouseEvent) : void
        {
            this.closeBtn();
            return;
        }// end function

        protected function rollOverHandler(event:MouseEvent) : void
        {
            this.showBtn();
            return;
        }// end function

        public function closeBtn() : void
        {
            this.btn.visible = false;
            return;
        }// end function

        public function set data(param1:Object) : void
        {
            this._data = param1;
            if (param1 == null)
            {
                this.visible = false;
                return;
            }
            var _loc_2:* = param1.name;
            this._Nmtxt.text = param1.name;
            if (this.data.hasOwnProperty("level"))
            {
                this._Nmtxt.color = 52479;
                this.leveltxt.color = MColor.New9;
                this.leveltxt.text = "(" + this.data.level + "级)";
            }
            else
            {
                this.leveltxt.color = MColor.New1;
                this._Nmtxt.color = 52479;
                this.leveltxt.text = "";
            }
            return;
        }// end function

        public function get data() : Object
        {
            return this._data;
        }// end function

        private function showBtn() : void
        {
            if (this.btn.visible)
            {
                return;
            }
            this.btn.visible = true;
            this.btn.y = 0;
            TweenLite.to(this.btn, 0.5, {y:-18});
            return;
        }// end function

        public function setpivotXY(param1:int, param2:int) : void
        {
            this.x = param1 - 22;
            this.y = param2 - 23;
            return;
        }// end function

    }
}
